﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using XiaoYuStock.Core;
using XiaoYuStock.Model.Models;
using XiaoYuStockAnalysis.BusinessLogic.Business;
using XiaoYuStock.WebApp.Helpers;
namespace XiaoYuStock.WebApp.Controllers
{
    public class BaseController : Controller
    {

        public BaseController()
        {
   
        }

        protected override void OnActionExecuting(ActionExecutingContext filterContext)
        {
            //var noAuthorizeAttributes = filterContext.ActionDescriptor.GetCustomAttributes(typeof(AuthorizeIgnoreAttribute), false);
            //if (noAuthorizeAttributes.Length > 0)
            //    return;

            base.OnActionExecuting(filterContext);

            if (!LoginUserManager.IsLogin)
            {
                filterContext.Result = RedirectToAction("Login", "Auth", new { rurl = filterContext.HttpContext.Request.Url.AbsoluteUri });
                return;
            }
        }

        public ContentResult RefreshParent(string alert = null)
        {
            var script = string.Format("<script>{0}; parent.location.reload(1)</script>", string.IsNullOrEmpty(alert) ? string.Empty : "alert('" + alert + "')");
            return this.Content(script);
        }


      
    }
}
